home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / PInterfaces / WorldScript.p < prev   
Encoding:
Text File  |  1994-07-21  |  9.3 KB  |  361 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        WorldScript.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.1  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT WorldScript;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __WORLDSCRIPT__}
  27. {$SETC __WORLDSCRIPT__ := 1}
  28.  
  29. {$I+}
  30. {$SETC WorldScriptIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __TRAPS__}
  40. {$I Traps.p}
  41. {$ENDC}
  42.  
  43. {$IFC UNDEFINED __QUICKDRAWTEXT__}
  44. {$I QuickdrawText.p}
  45. {$ENDC}
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.  
  51. CONST
  52.     kVariableLengthArray        = 1;
  53.  
  54.     
  55. TYPE
  56. WSIOffset = UInt16;
  57.  
  58.     WSIByteCount = UInt8;
  59.  
  60.     WSIByteIndex = UInt8;
  61.  
  62. { offset from start of sub-table to row in state table }
  63.     WSIStateOffset = UInt16;
  64.  
  65.     WSITableOffset = UInt32;
  66.  
  67.     WSISubtableOffset = UInt16;
  68.  
  69.     WSIGlyphcode = UInt16;
  70.  
  71.     WSITableIdentifiers = UInt32;
  72.  
  73.  
  74. CONST
  75.     kScriptSettingsTag            = 'info';
  76.     kMetamorphosisTag            = 'mort';
  77.     kGlyphExpansionTag            = 'g2g#';
  78.     kPropertiesTag                = 'prop';
  79.     kJustificationTag            = 'kash';
  80.     kCharToGlyphTag                = 'cmap';
  81.     kGlyphToCharTag                = 'pamc';
  82.     kFindScriptRunTag            = 'fstb';
  83.  
  84. {***             L O O K U P    T A B L E    T Y P E S        ***}
  85.     WSILookupSimpleArray        = 0;                            { a simple array indexed by glyph code }
  86.     WSILookupSegmentSingle        = 2;                            { segment mapping to single value }
  87.     WSILookupSegmentArray        = 4;                            { segment mapping to lookup array }
  88.     WSILookupSingleTable        = 6;                            { sorted list of glyph, value pairs }
  89.     WSILookupTrimmedArray        = 8;                            { a simple trimmed array indexed by glyph code }
  90.  
  91.     
  92. TYPE
  93. WSILookupTableFormat = INTEGER;
  94.  
  95.     WSILookupValue = INTEGER;
  96.  
  97. { An offset from the beginning of the lookup table }
  98.     WSILookupOffset = INTEGER;
  99.  
  100. {    FORMAT SPECIFIC DEFINITIONS }
  101. {
  102.         lookupSimpleArray:
  103.         
  104.         This is a simple array which maps all glyphs in the font
  105.         to lookup values.
  106.     }
  107.     WSILookupArrayHeader = RECORD
  108.         lookupValues:            ARRAY [0..0] OF WSILookupValue;            { The array of values indexed by glyph code }
  109.     END;
  110. {
  111.         lookupTrimmedArray:
  112.         
  113.         This is a single trimmed array which maps a single range
  114.         of glyhs in the font to lookup values.
  115.     }
  116.     WSILookupTrimmedArrayHeader = RECORD
  117.         firstGlyph:                WSIGlyphcode;
  118.         limitGlyph:                WSIGlyphcode;
  119.         valueArray:                ARRAY [0..0] OF WSILookupValue;
  120.     END;
  121. { The format specific part of the subtable header }
  122.     WSILookupFormatSpecificHeader = RECORD
  123.         CASE INTEGER OF
  124.         0: (
  125.             lookupArray:                WSILookupArrayHeader;
  126.            );
  127.         1: (
  128.             trimmedArray:                WSILookupTrimmedArrayHeader;
  129.            );
  130.     END;
  131.  
  132. { The overall subtable header }
  133.     WSILookupTableHeader = RECORD
  134.         format:                    WSILookupTableFormat;                    { table format }
  135.         fsHeader:                WSILookupFormatSpecificHeader;            { format specific header }
  136.     END;
  137. {***        G L Y P H    E X P A N S I O N    ***}
  138.  
  139. CONST
  140. { fixed 1.0 }
  141.     kCurrentGlyphExpansionVersion = $00010000;
  142.  
  143.     
  144. TYPE
  145. GlyphExpansionFormats = INTEGER;
  146.  
  147.  
  148. CONST
  149.     GlyphExpansionLookupFormat    = 1;
  150.     GlyphExpansionContextualFormat = 2;
  151.  
  152.  
  153. TYPE
  154.     ExpandedGlyphCluster = PACKED RECORD
  155.         numGlyphs:                WSIByteCount;
  156.         bestGlyph:                WSIByteIndex;
  157.         glyphs:                    ARRAY [0..0] OF WSIGlyphcode;
  158.     END;
  159.     ExpandedGlyphOffset = RECORD
  160.         glyph:                    WSIGlyphcode;
  161.         offset:                    WSIOffset;                                { offset to ExpandedGlyphCluster }
  162.     END;
  163.     GlyphExpansionStateTable = RECORD
  164.         stateTableOffset:        WSISubtableOffset;
  165.         classTableOffset:        WSISubtableOffset;
  166.         actionTableOffset:        WSISubtableOffset;                        { state, class and actions tables follow here... }
  167.     END;
  168.     GlyphExpansionTable = RECORD
  169.         version:                Fixed;
  170.         format:                    INTEGER;
  171.         expansionNumer:            INTEGER;
  172.         expansionDenom:            INTEGER;                                { num/denom ratio for expansion <2> }
  173.         CASE INTEGER OF
  174.         0: (
  175.             stateTable:                    GlyphExpansionStateTable;
  176.            );
  177.         1: (
  178.             lookup:                        WSILookupTableHeader;                { expanded glyph clusters follow here... }
  179.            );
  180.     END;
  181.  
  182. { Glyph-to-Character constants and types  }
  183.  
  184. CONST
  185.     kCurrentGlyphToCharVersion    = $00010100;
  186.  
  187.     
  188. TYPE
  189. GlyphToCharLookupFormats = INTEGER;
  190.  
  191.  
  192. CONST
  193.     kGlyphToCharLookup8Format    = 1;
  194.     kGlyphToCharLookup16Format    = 2;
  195.     kGlyphToCharLookup32Format    = 3;
  196.  
  197.     
  198. TYPE
  199. GlyphToCharFontIndex = UInt8;
  200.  
  201.     QDGlyphcode = UInt8;
  202.  
  203.     GlyphToCharActionTable = RECORD
  204.         fontNameOffset:            WSISubtableOffset;                        { offset relative to this table }
  205.         actions:                WSILookupTableHeader;                    { only support lookupSimpleArray format for now }
  206.     END;
  207.     GlyphToCharActionHeader = RECORD
  208.         numTables:                INTEGER;                                { 0..n }
  209.         offsets:                ARRAY [0..0] OF WSISubtableOffset;        { offsets from start of action table header }
  210.     END;
  211.     GlyphToCharHeader = RECORD
  212.         version:                Fixed;
  213.         actionOffset:            WSISubtableOffset;                        { offset to GlyphToCharActionHeader }
  214.         format:                    INTEGER;                                { size of font mask }
  215.         mappingTable:            WSILookupTableHeader;
  216.     END;
  217. { JUSTIFICATION TYPES
  218.     WorldScript supports justification of text using insertion. The justification
  219.     table specifies a insertion string to insert between 2 specified glyphs.
  220.     Each combination of inter-glyph boundary can be assigned a justification priority,
  221.     the higher the priority the more justification strings inserted at that position.
  222.     
  223.     The priorities for each inter-glyph boundary are specified by the justification table's
  224.     state table.
  225.     
  226.     Special handling is done for scripts which use spaces to justify, because the width of 
  227.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  228.     per inserting string is specified in the justification table.
  229.  
  230. }
  231.  
  232. CONST
  233. { 1.0 not supported }
  234.     kCurrentJustificationVersion = $0200;
  235.  
  236.     kJustificationStateTableFormat = 1;
  237.  
  238. { WSI's internal limitation <12> }
  239.     kMaxJustificationStringLength = 13;
  240.  
  241.     
  242. TYPE
  243. WSIJustificationPriority = UInt8;
  244.  
  245.  
  246. CONST
  247.     WSIJustificationSetMarkMask    = $80;
  248.  
  249.  
  250. TYPE
  251.     WSIJustificationStateEntry = PACKED RECORD
  252.         markPriority:            WSIJustificationPriority;                { non-zero priorities means insertion }
  253.         priority:                WSIJustificationPriority;
  254.         newState:                WSIStateOffset;
  255.     END;
  256.     WSIJustificationClasses = INTEGER;
  257.  
  258.  
  259. CONST
  260.     wsiJustEndOfLineClass        = 0;
  261.     wsiJustEndOfRunClass        = 1;
  262.     wsiJustDeletedGlyphClass    = 2;
  263.     wsiJustUserDefinedClass        = 3;
  264.  
  265.     
  266. TYPE
  267. WSIJustificationStates = INTEGER;
  268.  
  269.  
  270. CONST
  271.     wsiStartOfLineState            = 0;                            { pre-defined states }
  272.     wsiStartOfRunState            = 1;
  273.     wsiUserDefinedState            = 2;
  274.  
  275. { pre-multiplied: class# * sizeof(WSIJustificationStateEntry) }
  276.     
  277. TYPE
  278. WSIJustificationClassOffset = UInt8;
  279.  
  280.     WSIJustificationStateTable = RECORD
  281.         maxPriorities:            INTEGER;
  282.         rowWidth:                INTEGER;                                { width of a state table row in bytes }
  283.         classTableOffset:        INTEGER;
  284.         stateTableOffset:        INTEGER;
  285.     END;
  286.     WSIJustificationHeader = RECORD
  287.         version:                INTEGER;
  288.         format:                    INTEGER;
  289.         scaling:                Point;                                    { numer/denom scaling of priority weights <7> }
  290.         spacesPerInsertion:        INTEGER;                                { # of $20 chars in justification insertion string <12> }
  291.         justStringOffset:        INTEGER;                                { offset to justification string }
  292.         stateTable:                WSIJustificationStateTable;                { long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows }
  293.     END;
  294. { Line Layout's Property table version <11> }
  295.  
  296. CONST
  297. { v1.0 }
  298.     currentPropsTableVersion    = $00010000;
  299.  
  300. { ??? is this right }
  301.     kCharToGlyphCurrentVersion    = 0100;
  302.  
  303. { pass as priorityWeight to JustifyWSILayout to use script's current just setting }
  304.     kScriptsDefaultJustWeight    = -1;
  305.  
  306.  
  307. TYPE
  308.     WSIGlyphInfoRec = RECORD
  309.         qdChar:                    SInt8;
  310.         rightToLeft:            SInt8;                                    { !0 means rightToLeft, 0 means leftToRight }
  311.         fontID:                    INTEGER;
  312.         originalOffset:            INTEGER;                                { or negative original offset if not in original text input }
  313.         unused:                    INTEGER;                                { long-align }
  314.     END;
  315.     WSIGlyphInfoRecPtr = ^WSIGlyphInfoRec;
  316.     WSIGlyphInfoHandle = ^WSIGlyphInfoRecPtr;
  317.  
  318.     WSILayoutHandle = Handle;
  319.  
  320.  
  321. FUNCTION NewWSILayout(layoutH: WSILayoutHandle; text: Ptr; txLength: INTEGER; lineDirection: INTEGER; flags: LONGINT; VAR err: OSErr): WSILayoutHandle;
  322.     {$IFC NOT GENERATINGCFM}
  323.     INLINE $2F3C, $8414, $0040, $A8B5;
  324.     {$ENDC}
  325. FUNCTION JustifyWSILayout(layoutH: WSILayoutHandle; slop: Fixed; priorityWeight: INTEGER; styleRunPosition: JustStyleCode; numer: Point; denom: Point; VAR err: OSErr): WSILayoutHandle;
  326.     {$IFC NOT GENERATINGCFM}
  327.     INLINE $2F3C, $8418, $0042, $A8B5;
  328.     {$ENDC}
  329. FUNCTION MeasureWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point): Fixed;
  330.     {$IFC NOT GENERATINGCFM}
  331.     INLINE $2F3C, $840C, $0044, $A8B5;
  332.     {$ENDC}
  333. PROCEDURE DrawWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point);
  334.     {$IFC NOT GENERATINGCFM}
  335.     INLINE $2F3C, $800C, $0046, $A8B5;
  336.     {$ENDC}
  337. { "low-level" routines }
  338. FUNCTION GetWSILayoutParts(layoutH: WSILayoutHandle; destH: WSIGlyphInfoHandle; VAR numGlyphs: INTEGER; VAR err: OSErr): WSIGlyphInfoHandle;
  339.     {$IFC NOT GENERATINGCFM}
  340.     INLINE $2F3C, $8410, $0048, $A8B5;
  341.     {$ENDC}
  342. PROCEDURE DrawWSIGlyphs(length: INTEGER; qdCodes: Ptr; numer: Point; denom: Point);
  343.     {$IFC NOT GENERATINGCFM}
  344.     INLINE $2F3C, $800E, $004A, $A8B5;
  345.     {$ENDC}
  346. FUNCTION xMeasureWSIGlyphs(VAR qdCodes: Ptr; length: INTEGER; numer: Point; denom: Point): Fixed;
  347.     {$IFC NOT GENERATINGCFM}
  348.     INLINE $2F3C, $840E, $004C, $A8B5;
  349.     {$ENDC}
  350.  
  351. {$ALIGN RESET}
  352. {$POP}
  353.  
  354. {$SETC UsingIncludes := WorldScriptIncludes}
  355.  
  356. {$ENDC} {__WORLDSCRIPT__}
  357.  
  358. {$IFC NOT UsingIncludes}
  359.  END.
  360. {$ENDC}
  361.